package com.antball.dd.mediator;

public class ConcreteMediator extends Mediator {


    @Override
    public void registered(int nWho, Colleague aColleague) {
        Colleague itr = m_mpColleague.get(nWho);
        if(itr == null)
        {
            m_mpColleague.put(nWho,aColleague);

            //同时将中介类暴露给colleague
            aColleague.setMediator(this);
        }
    }

    @Override
    public void operation(int nWho, String str) {
        Colleague itr = m_mpColleague.get(nWho);
        if(itr == null)
        {
            System.out.println("not found this colleague!");
            return;
        }

        itr.receivemsg(str);
    }
}
